#pragma once


// CColorBox

class CColorBox : public CWnd
{
	DECLARE_DYNAMIC(CColorBox)
	COLORREF m_clPen {}, m_clBrush{0xffffff};
	int m_nIndex{};
	enum {
		COLOR_SELECT = RGB(201, 224, 247),
		COLOR_BORDER = RGB(98, 162, 228),
		COLOR_FRAME = RGB(182, 128, 128)
	};
	const COLORREF COLOR_NORMAL = GetSysColor(COLOR_BTNFACE);
	const COLORREF COLOR_SHADOW = GetSysColor(COLOR_BTNSHADOW);
	static COLORREF m_cs[30];

public:
	CColorBox();
	virtual ~CColorBox();
	BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
	COLORREF GetPenColor() const {
		return m_clPen;
	}
	COLORREF GetBlushColor() const {
		return m_clBrush;
	}
	void SetPenColor(COLORREF col, BOOL bRedraw = FALSE) {
		m_clPen = col;
		if (bRedraw) {
			CRect rect;
			GetClientRect(rect);
			int nHeight = rect.Height();
			InvalidateRect(CRect(0, 0, nHeight, nHeight), FALSE);
		}
	}
	void SetBlushColor(COLORREF col, BOOL bRedraw = FALSE) {
		m_clBrush = col;
		if (bRedraw) {
			CRect rect;
			GetClientRect(rect);
			int nHeight = rect.Height();
			InvalidateRect(CRect(0, 0, nHeight, nHeight), FALSE);
		}
	}
	void DrawLeft(CDC* pDC, int nHeight);
	void DrawRight(CDC* pDC, int nHeight);
	void DrawSelection(CDC* pDC, int nHeight);
	void DrawBoxes(CDC* pDC, int nHeight);
	void DrawButton(CDC* pDC);
	int GetBoxIndex(CPoint point, int nHeight);

protected:
	DECLARE_MESSAGE_MAP()
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};


